import {
  staticCount
} from '~/services/api/login'
import Toast from 'tdesign-miniprogram/toast/index';
Page({
  /**
   * 页面的初始数据
   */
  data: {
    activeIndex: 0,
    countInfo: {

    },
    dataArr: [
      // {"今日":'newDatasByToday'},
      // {"本周":"newDatasByWeek"},
      // {"本月":"newDatasByMonth"}
      {
        label: "今日",
        eng: 'newDatasByToday'
      },
      {
        label: "本周",
        eng: 'newDatasByWeek'
      },
      {
        label: "本月",
        eng: 'newDatasByMonth'
      }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    this.initData()
  },
  onShow() {
    this.initData()
  },
  async initData() {
    let {
      data,
      code
    } = await staticCount()
    console.log(data, code);
    console.log(Object.keys(data));
    if (code == 200) {
      // this.countInfo =  data;
      this.setData({
        countInfo: data
      })
    }
  },
  navOrder() {
    wx.navigateTo({
      // subpages/pages/order/order-list/index
      url: '/subpages/pages/storeOrder/index',
    })
  },
  navNews() {
    wx.switchTab({
      url: '/pages/news/news',
    })
  },
  tapList(e) {
    console.log(e);
    this.setData({
      activeIndex: e.currentTarget.dataset.index
    })
  },

  async initData() {
    let {
      data,
      code
    } = await staticCount()
    console.log(data, code);
    console.log(Object.keys(data));
    if (code == 200) {
      // this.countInfo =  data;
      this.setData({
        countInfo: data
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getTabBar().init();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
  nav() {
    wx.navigateTo({
      url: '/subpages/pages/allTeams/allTeams',
    });
  },
  navTerminal() {
    wx.navigateTo({
      url: '/subpages/pages/allTerminal/allTerminal',
    });
  },
  navAllMenber() {
    wx.navigateTo({
      url: '/subpages/pages/allMenber/allMenber',
    });
  },
  addNewCategory() {
    wx.navigateTo({
      url: '/subpages/pages/addCategory/addCategory',
    });
  },
  // 新增代理商
  navAgent() {
    wx.navigateTo({
      url: '/subpages/pages/addNewAgent/addNewAgent',
    });
  },
  // 新增报表
  navBotForm() {
    wx.navigateTo({
      url: '/subpages/pages/addBotForm/addBotForm',
    });
  },
  addProduct() {
    wx.navigateTo({
      url: '/subpages/pages/add-goods/add-goods',
    });
  },
  // 审核列表
  checkListFn() {
    wx.navigateTo({
      url: '/subpages/pages/examineList/examineList',
    });
  },

  // 产品管理
  navToProduct() {
    wx.navigateTo({
      url: '/subpages/pages/goods/category/index',
    });
  },
  notDesign() {
    Toast({
      context: this,
      selector: '#t-toast',
      message: '暂未开发，敬请期待',
    });
  },
  activePlan() {
    wx.navigateTo({
      url: '/subpages/pages/activePlan/list/list',
    });
  },
  navSuggest() {
    wx.navigateTo({
      url: '/subpages/pages/suggestList/suggestList',
    });
  }
});